package com.cy.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cy.entity.Admin;
import com.cy.entity.JsonResult;
import com.cy.service.AdminService;

@RestController
public class AdminController {
	@Autowired
	private AdminService adminService;
	
	@RequestMapping("adminLogin")
	public JsonResult adminLogin(@RequestBody Map<String, String> map) {
		System.out.println(map);
		String tel = map.get("tel");
		String password = map.get("password");
		List<Admin> list = adminService.login(tel, password);
		if (list.size()>0) {
			
			return new JsonResult(list.get(0));
		}
		return new JsonResult(1,"用户名或密码错误！");
		
	}
	
}